package IO流;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class FileCopeTool {
    //定义文件拷贝工具类
    public static void main(String[] args) {
            copeFile("E:/yk.jpg","e:/hahha.jpg");
    }
    public static void copeFile(String src,String des){
        FileInputStream fis=null;
        BufferedInputStream bis=null;
        FileOutputStream fos=null;
        BufferedOutputStream bos=null;
        try {
            bis=new BufferedInputStream(new FileInputStream(src));
            bos=new BufferedOutputStream(new FileOutputStream(des));
            int temp=0;
            while((temp=bis.read())!=-1){
                bos.write(temp);
            }
            bos.flush();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try {
                if(bis!=null)bis.close();;
                if(fis!=null)fis.close();
                if(bos!=null)bos.close();
                if(fos!=null)fos.close();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
